home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Development Tools & Languages / Dylan Related / Marlais / Marlais 0.5.9-portable sources / env.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-15  |  3.4 KB  |  109 lines  |  [TEXT/ttxt]

  1. /*
  2.  
  3.    env.h
  4.  
  5.    This software is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License as published by the Free Software Foundation; either
  8.    version 2 of the License, or (at your option) any later version.
  9.  
  10.    This software is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    Library General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU Library General Public
  16.    License along with this software; if not, write to the Free
  17.    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.    Original copyright notice follows:
  20.  
  21.    Copyright, 1993, Brent Benson.  All Rights Reserved.
  22.    0.4 & 0.5 Revisions Copyright 1994, Joseph N. Wilson.  All Rights Reserved.
  23.  
  24.    Permission to use, copy, and modify this software and its
  25.    documentation is hereby granted only under the following terms and
  26.    conditions.  Both the above copyright notice and this permission
  27.    notice must appear in all copies of the software, derivative works
  28.    or modified version, and both notices must appear in supporting
  29.    documentation.  Users of this software agree to the terms and
  30.    conditions set forth in this notice.
  31.  
  32.  */
  33.  
  34. #ifndef ENV_H
  35. #define ENV_H
  36.  
  37. #include "object.h"
  38.  
  39. struct binding {
  40.     Object sym, *val, type;
  41.     int props;
  42.     struct binding *next;    /* in top_level_env hash chain */
  43. };
  44.  
  45. #define CONSTANT_BINDING 0x01
  46. #define IMPORTED_BINDING 0x02
  47. #define EXPORTED_BINDING 0x04
  48.  
  49. #define IS_IMPORTED_BINDING(binding) (binding->props & IMPORTED_BINDING)
  50. #define IS_CONSTANT_BINDING(binding) (binding->props & CONSTANT_BINDING)
  51. #define IS_EXPORTED_BINDING(binding) (binding->props & EXPORTED_BINDING)
  52.  
  53.  
  54. struct module_binding {
  55.     Object sym;
  56.     struct frame *namespace;
  57.     Object exported_bindings;
  58. };
  59.  
  60. struct frame {
  61.     int size;
  62.     Object owner;
  63.     struct binding **bindings;
  64.     struct frame *next;
  65.     struct binding **top_level_env;
  66. };
  67.  
  68. extern struct frame *the_env;
  69. extern Object default_module;
  70. extern Object all_symbol;
  71.  
  72. void init_env_prims (void);
  73.  
  74. void add_top_level_binding (Object sym, Object val, int constant);
  75. void push_scope (Object owner);
  76. void pop_scope (void);
  77. Object print_env (struct frame *env);
  78. Object show_bindings (Object args);
  79.  
  80. /* Warning!!! - you can't mix calls to add_bindings() and
  81.    add_binding() within the same frame.  Things will get
  82.    hopelessly screwed up.
  83.  */
  84. void add_bindings (Object syms, Object vals, int constant);
  85. void add_binding (Object sym, Object val, int constant);
  86. int change_binding (Object sym, Object val);
  87.  
  88. Object symbol_value (Object sym);
  89. void modify_value (Object sym, Object new_val);
  90. struct frame *current_env (void);
  91. void unwind_to_exit (Object exit_sym);
  92. struct binding *symbol_binding_top_level (Object sym);
  93. struct frame *module_namespace ();
  94. struct module_binding *new_module (Object module_name);
  95. struct module_binding *set_module (struct module_binding *module);
  96. Object use_module (Object module_name,
  97.            Object imports,
  98.            Object exclusions,
  99.            Object prefix,
  100.            Object renames,
  101.            Object exports);
  102. Object user_set_module (Object args);
  103. struct module_binding *current_module (void);
  104. struct module_binding *module_binding (Object module_name);
  105. Object make_environment (struct frame *env);
  106. void fill_table_from_property_set (Object the_table, Object the_set);
  107.  
  108. #endif
  109.